#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
int g(int n,int k)
{
	int sum=0;
	while(n){
		sum+=n/k;
		n/=k;
	}
	return sum;
} 
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	printf("%d",g(n,k));
	return 0;
}
